package com.zyl.blog.tasks.schedule.tasks;

import com.zyl.blog.common.utils.Extreme.LogUtil;
import com.zyl.blog.tasks.annotation.TaskLog;
import com.zyl.blog.tasks.enums.TaskTriggerMode;
import com.zyl.blog.tasks.enums.TaskType;
import com.zyl.blog.tasks.schedule.abstracts.AbstractScheduledTask;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


/**
 * CRON任务示例
 * @version v1.0
 * @ProjectName: Personal_Blog_Server
 * @Package: com.zyl.blog.tasks.schedule.tasks
 * @ClassName: ExampleCronTask
 * @Description:
 * @Author FinalFantasy
 * @Date 2025/8/13-08:43
 */
@Component
public class ExampleCronTask extends AbstractScheduledTask {

    @Override
    public String getTaskName() {
        return "exampleCronTask";
    }

    @Override
    public String getTaskDescription() {
        return "示例CRON任务，每分钟执行一次";
    }

    @TaskLog(
            taskType = "DATA_SYNC",
            triggerMode = TaskTriggerMode.AUTO,
            retryTimes = 2
    )
    @Override
    public void execute() {
        LogUtil.info("示例CRON任务执行: " + LocalDateTime.now());
    }

    @Override
    public TaskType getScheduleType() {
        return TaskType.CRON;
    }

    @Override
    public String getCronExpression() {
        // 每秒钟执行一次
        return "0/1 * * * * *";
    }

    @Override
    public String getUsername() {
        return "admin"; // 任务所属用户
    }

    @Override
    public Boolean startBoot() {
        return true;
    }
}